﻿using Microsoft.Extensions.DependencyInjection;
using Modules.App.Repositories;
using PmSoft;

namespace Modules.App;


/// <summary>
/// app版本控制服务
/// </summary>
[UseDI(ServiceLifetime.Scoped)]
public class AppVersionService
{
    private readonly AppVersionRepository appVersionRepository;

    public AppVersionService(AppVersionRepository appVersionRepository)
    {
        this.appVersionRepository = appVersionRepository;
    }

    /// <summary>
    /// app版本控制表单详情
    /// </summary>
    /// <param name="id">主键</param>
    /// <returns></returns>
    public AppVersion? Get(int id)
    {
        return appVersionRepository.Get(id);
    }

    public IEnumerable<AppVersion> GetAll()
    {
        return appVersionRepository.GetAll();
    }

    /// <summary>
    /// 批量删除，根据id
    /// </summary>
    /// <param name="ids">id的集合</param>
    public void Deleted(IEnumerable<int> ids)
    {
        foreach (int id in ids)
        {
            Delete(id);
        }
    }

    /// <summary>
    /// 单个删除
    /// </summary>
    /// <param name="id">主键</param>
    public void Delete(int id)
    {
        appVersionRepository.DeleteByEntityId(id);
    }

    /// <summary>
    /// 创建app版本控制
    /// </summary>
    /// <param name="entity">实体对象</param>
    public void Create(AppVersion entity)
    {
        appVersionRepository.Insert(entity);
    }

    /// <summary>
    /// 编辑app版本控制
    /// </summary>
    /// <param name="entity">实体对象</param>
    public void Update(AppVersion entity)
    {
        appVersionRepository.Update(entity);
    }

}